package io.gitee.xyuesheng.day09;

public class Producer implements Runnable {
    private Factory factory;

    private int id = 0;

    public Producer(Factory factory) {
        this.factory = factory;
    }

    @Override
    public void run() {
        //每隔0-20ms，网工厂里面返回一个产品
        while (true) {
            try {
                Thread.sleep((long) (Math.random() * 20));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            this.factory.put(new Integer(id));
            id++;
        }
    }
}
